<?php


namespace app\api\model;


use think\Model;
use traits\model\SoftDelete;
use think\Db;

class Tryride extends Model
{
    protected $name = 'tryride';
    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public static function endtoTryride()
    {
        $tryride = self::where(['status'=>1])->select();
        foreach ($tryride as $vs) {
            $endtime = strtotime($vs['startTime'])+$vs['time_unit']+172800;
            if (time()>=$endtime) {//超过2天
                Db::name('tryride')->where(['id'=>$vs['id']])->update(['status'=>3,'endTime'=>date('Y-m-d H:i:s')]);
            }
        }
    }
}